package com.mshine.cloud.controller;

import com.alibaba.fastjson.JSON;
import com.codingapi.txlcn.tc.annotation.DTXPropagation;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.mshine.cloud.mybatis.entity.TbUser;
import com.mshine.cloud.mybatis.mapper.TbUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    TbUserMapper tbUserMapper;

    @RequestMapping("/test")
    @LcnTransaction(propagation = DTXPropagation.SUPPORTS)
    @Transactional
    public String test() {
        TbUser tbUser = new TbUser();
        tbUser.setName("AAAAAAA" + System.currentTimeMillis());
        tbUserMapper.insert(tbUser);
        return JSON.toJSONString(tbUser);
    }
}
